//
//  RelateTableViewCell.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/15.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "RelateTableViewCell.h"

@implementation RelateTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.leftImage = [[UIImageView alloc] init];
        [self addSubview:self.leftImage];
        self.titleLabel = [[UILabel alloc] init];
        [self addSubview:self.titleLabel];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        
        self.bottomLeftImage = [[UIImageView alloc] init];
        self.bottomLeftImage.image = [UIImage imageNamed:@"album_tracks@3x"];
        [self addSubview:self.bottomLeftImage];
        
        
        self.countLabel = [[UILabel alloc] init];
        self.countLabel.textColor = [UIColor grayColor];
        self.countLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.countLabel];
        
        
        //时间和日期图像内容
        
        self.clockImage = [[UIImageView alloc] init];
        self.clockImage.image = [UIImage imageNamed:@"clock"];
        [self addSubview:self.clockImage];
        self.dateLabel = [[UILabel alloc] init];
        self.dateLabel.font = [UIFont systemFontOfSize:13];
        self.dateLabel.textColor = [UIColor grayColor];
        [self addSubview:self.dateLabel];
        
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.leftImage.frame = CGRectMake(5, 5, self.height - 10, self.height - 10);
    self.titleLabel.frame = CGRectMake(self.leftImage.right + 5, self.leftImage.top, self.width - self.leftImage.right - 10, self.leftImage.height / 2);
    
    
    self.bottomLeftImage.frame = CGRectMake(self.titleLabel.left, self.leftImage.bottom - 20, 20, 20);
    self.countLabel.frame = CGRectMake(self.bottomLeftImage.right + 5, self.bottomLeftImage.top, 100, self.bottomLeftImage.height);
    self.clockImage.frame = CGRectMake(self.countLabel.right + 10, self.countLabel.top, 20, 20);
    self.dateLabel.frame = CGRectMake(self.clockImage.right + 5, self.countLabel.top, 100, 20);
}

- (void)setRelateModel:(RelateModel *)relateModel {
    if (_relateModel != relateModel) {
        _relateModel = relateModel;
    }
    
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:self.relateModel.coverMiddle]];
    self.titleLabel.text = self.relateModel.title;
    self.countLabel.text = [NSString stringWithFormat:@"%.1f万", self.relateModel.playsCounts.floatValue / 10000];
    self.dateLabel.text = [TimeInteval shareGetUTCFormateDate:[NSString stringWithFormat:@"%ld", self.relateModel.updatedAt.integerValue / 1000]];
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
